def partition(numbers, number): # DO NOT modify this line 
    # TODO: add your code here
    smaller = [n for n in numbers if n < number]
    not_smaller = [n for n in numbers if n >= number]
    
    index = len(smaller)
    numbers[:] = smaller + [number] + not_smaller
    return index

# === DO NOT modify the code below ===
def main():
    numbers = [eval(x) for x in input().split()]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str, numbers)))
    print(index)
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===
